//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <cstdlib>

#include <iostream>
#include <fstream>

#include "ComplexesDB.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main(int argc, char** argv) {

  String* location;
  String* result;
  
  if (argc < 3) {
    cout << "Error in the input arguments. The execution must be: " << endl;
    cout << "./GetComplexesFromPDB <Path of the folder with pdb files> <path of output result>" << endl;
    return 0;
  }
  else {
    cout << "---------------------------------------------------------------------------------" << endl;
    cout << "Reading files inside the folder: " << argv[1] << endl;
    cout << "          The Output Folder is : " << argv[2] << endl;
    cout << "---------------------------------------------------------------------------------" << endl;
    location = new String(argv[1]);
    result   = new String(argv[2]);
  }

  ComplexesDB* complexes = new ComplexesDB();

  complexes->LocationDB(location);
  complexes->GetListComplexesWithRestrictions();

  cout << "---------------------------------------------------------------------------------" << endl;
  cout << "Creating the list of complex pdb files" << endl;

  fstream outFile;
  
  outFile.open(result->Out(), fstream::out);
  
  complexes->ListIDPDB()->SetInitial();
  while (complexes->ListIDPDB()->SetNext()) {
    outFile << complexes->ListIDPDB()->GetCurrent()->Out() << endl;
  }

  outFile.close();

  cout << "---------------------------------------------------------------------------------" << endl;
  
  if (complexes) delete complexes;
  if (result)    delete result;

  return 1;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

